<script lang="ts" setup>
const route = useRoute();
const { classicGames, typeGameMap } = useGamesData();
const type = computed<any>(() => route.query.type);
const currTypeGames = computed(() =>
  unref(type) == "Classic"
    ? unref(classicGames)
    : unref(typeGameMap[unref(type)])
);
// 取出前6个游戏
const sixGames = computed(() => {
  return currTypeGames.value.slice(0, 6);
});
// 取出后面剩余的游戏
const restGames = computed(() => {
  return currTypeGames.value.slice(6);
});

const ad4 = useGoogleAd("ad4");
</script>
<template>
  <div>
    <Search class="mb-[13px_!important]" />
    <Featured
      v-if="sixGames.length"
      class="mb-[24px_!important]"
      :title="`${type} Games`"
      :data="sixGames"
    />
    <Advert v-bind="ad4" class="mb-24" />
    <GameList v-if="restGames.length" :data="restGames" />
  </div>
</template>
